$(function() {
	
	$( '#editor_kama' ).ckeditor(function(){},{
		skin : 'kama',
		smiley_path :  contextPath + "/fckeditor/data/yoyo/",
		smiley_images : ['002.gif','003.gif','004.gif','005.gif',
						'006.gif','007.gif','008.gif','009.gif','010.gif',
						'011.gif','012.gif','013.gif','014.gif','015.gif',
						'016.gif','017.gif','018.gif','019.gif','020.gif',
						'021.gif','022.gif','023.gif','024.gif','025.gif',
						'026.gif','027.gif','028.gif','029.gif','030.gif',
						'031.gif','032.gif','033.gif','034.gif','035.gif',
						'036.gif','037.gif','038.gif','039.gif','040.gif',
						'041.gif','042.gif','043.gif','044.gif','045.gif',
						'046.gif','047.gif']
	});
	
	
	$('#choose').bind('click',function(){
		var editor_data = CKEDITOR.instances.editor_kama.getData();
		$('#art_content').val(editor_data);
		var pass = true;
		$('.tip[passed]').each(function(){
			if($(this).attr("passed") == "false"){
				$(this).text("大哥，给点力啊……");
				$(this).css("color","red");
				pass = false;
			}
		});
		if( pass ){
			$('#artForm').submit();
		}else{
			return;
		}

	});
	
	$('#artContent').bind("click",function(){
		var result = WSLDS.Utils.openShowModal(
			contextPath + '/bk/listAllPhoto.action', 800, 450);	
		if(result){
//			alert(result);
			CKEDITOR.instances.editor_kama.insertHtml(result);
		}
	});
	
	$('#artTitle').bind("blur",function(){
		var tip = $(this).parent().parent().find('.tip');
		if( $.trim($(this).val()).length === 0 ){
			tip.text("大哥，给点力啊……");
			tip.css("color","red");
			tip.attr("passed","false");
		}else{
			tip.text("够给力……");
			tip.css("color","green");
			tip.attr("passed","true");
		}
	});

	
});